package cn.qrx.gateway.seesion.defaults;

import cn.qrx.gateway.bind.IGenericReference;
import cn.qrx.gateway.datasource.Connection;
import cn.qrx.gateway.datasource.DataSource;
import cn.qrx.gateway.datasource.DataSourceFactory;
import cn.qrx.gateway.datasource.unpooled.UnpooledDataSourceFactory;
import cn.qrx.gateway.mapping.HttpStatement;
import cn.qrx.gateway.seesion.Configuration;
import cn.qrx.gateway.seesion.GatewaySession;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.rpc.service.GenericService;

/**
 * @Author: 屈燃希
 * @Date:   2025/10/15
 * @Version: V1.0
 * @Description:
 */
public class DefaultGatewaySession implements GatewaySession {

    private Configuration configuration;

    private String uri;

    private DataSource dataSource;

    public DefaultGatewaySession(Configuration configuration, String uri, DataSource dataSource) {
        this.configuration = configuration;
        this.uri = uri;
        this.dataSource = dataSource;
    }

    @Override
    public Object get(String methodName, Object parameter) {

        Connection connection = dataSource.getConnection();
        return connection.execute(methodName,new String[]{"java.lang.String"}, new String[]{"name"}, new Object[]{parameter});

    }

    @Override
    public IGenericReference getMapper(String uri) {
        return configuration.getMapper(uri, this);
    }

    @Override
    public Configuration getConfiguration() {
        return configuration;
    }

}
